package com.qf.globalInterceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class Interceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HttpSession session = request.getSession();
        String requestURI = request.getRequestURI();
        session.setAttribute("url",requestURI);
//        session.setAttribute("name",1);
        if (session.getAttribute("name")==null) {
            response.sendRedirect("/login.jsp");
            return false;
        }
        return true;
    }
}
